﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WL_Store.BLL;
using WL_Store.Model;

namespace WL_Store.Web.subpage
{
    public partial class Orderform : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindOrderFeoms();
            }
        }

        private void BindOrderFeoms()
        {
            //获取用户输入的信息
            string OrderId = this.txt_OrderId.Text.Trim();


            DateTime? startOrderTime = null;
            if (!string.IsNullOrWhiteSpace(txt_StartOrderTime.Value.Trim()))
            {
                startOrderTime = Convert.ToDateTime(txt_StartOrderTime.Value.Trim());
            }

            DateTime? endOrderTime = null;
            if (!string.IsNullOrWhiteSpace(txt_EndOrderTime.Value.Trim()))
            {
                endOrderTime = Convert.ToDateTime(txt_EndOrderTime.Value.Trim());
            }

            OrderFormSearchModel searchModel = new OrderFormSearchModel()
            {
                orderID = OrderId,
                StartOrderTime = startOrderTime,
                EndOrderTime = endOrderTime

            };


            OrderFormBLL bll = new OrderFormBLL();

            List<OrderFormModel> models = bll.GetOrderForms(searchModel);

            rpt_OrderFroms.DataSource = models;
            rpt_OrderFroms.DataBind();
        }

        protected void btn_search_Click(object sender, EventArgs e)
        {
            BindOrderFeoms();
        }
    }

}